Skip to content

Add significant_figures and decimal_places grading parameters - #277

Open
m-messer wants to merge 7 commits into
mainfrom
feature/decimal_places
Open

Add significant_figures and decimal_places grading parameters#277
m-messer wants to merge 7 commits into
mainfrom
feature/decimal_places

Conversation

@m-messer

Copy link
Copy Markdown
Member

Requires #273.

Problem

Custom criteria had no way to grade a numeric response to a fixed number of significant
figures or decimal places — both for correctness and for the precision the response was
actually written to (e.g. rejecting 3.1 or 3.14159 when 3.14 is asked for). There was
also no fuzzy variant that derives a numerical tolerance from a sig-fig/decimal-place count
without checking written precision.

This PR merges in #273 (significant_figures/sig_figs and
significant_figures_tolerance/sig_figs_tol, still open/unmerged) and adds its decimal-place
counterpart, decimal_places/dp and decimal_places_tolerance/dp_tol, reusing the same
numeric-string helpers. The two features are combined in one branch here because
decimal_places builds directly on the sig_figs helpers/integration points, and #273's branch
had drifted behind main's bracket-matching work (#265/#274) and atol unit-factor fix (#272) —
merging it in first and resolving those conflicts made it possible to build decimal_places on a
consistent base rather than duplicating the shared code path across two divergent branches.

Changes

  • app/utility/expression_utilities.py: significant-figures helpers (round_to_sig_figs,
    split_numeric_string, count_sig_figs, sig_figs_match,
    relative_tolerance_from_sig_figs) from Add support for significant figures (sig_figs) parameter #273, plus new decimal-place helpers
    (round_to_decimal_places, count_decimal_places, decimal_places_match,
    absolute_tolerance_from_decimal_places) built on top of them.
  • app/evaluation.py: parses significant_figures/sig_figs,
    significant_figures_tolerance/sig_figs_tol, decimal_places/dp and
    decimal_places_tolerance/dp_tol; all four are mutually exclusive with each other and with
    atol/rtol; sig_figs_tol writes rtol, dp_tol writes atol.
  • app/context/symbolic.py, app/context/physical_quantity.py: integrate sig_figs/dp at
    the point each context decides a direct response = answer numeric match (before the
    ordinary equality/tolerance logic, since a value that's numerically equal but written to the
    wrong precision must still fail).
  • app/docs/user.md, app/docs/dev.md: user-facing parameter docs and developer notes for all
    four parameters, including the caveat that decimal_places with physical_quantity compares
    at the answer's SI scale (so is intended for same-unit responses), unlike the scale-invariant
    significant_figures.
  • Tests added across app/tests/expression_utilities_test.py,
    app/tests/symbolic_evaluation_test.py, app/tests/physical_quantity_evaluation_test.py for
    every new helper and both parameters (core cases, aliases, mutual-exclusion, invalid-value
    validation, physical-quantity/unit interaction).

Checklist

  • Tests added/updated
  • Docs updated (app/docs.md) if user-facing behaviour changed

Closes #

🤖 Generated with Claude Code

https://claude.ai/code/session_01PndQqZ1ZR2QQ1sYH3eNybZ

m-messer and others added 7 commits August 7, 2026 13:09
…rameter in evaluation, tests, and documentation
Resolved conflicts by keeping main's post-merge-base work (bracket
matching from #265/#274, atol unit-factor scaling from #272, order
operator fix from #275) while layering in the significant-figures
feature (sig_figs / sig_figs_tol).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PndQqZ1ZR2QQ1sYH3eNybZ
…(`dp_tol`) parameters in evaluation, with tests and documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant